Predefinição:Tabela de classes/doc
Description This template used to be a simple redirect to the template. It has been modified to automatically generate categories for each class/level combination listed in the table. It is intended to be used in the template and any other template the describes a creature that has a "class" and a "level". The generation of categories is optional and will only occur if the edição parameter is set. Example This is an example of the template being used inside the template (most parts of template not shown). | alignment = ... }} | resanterior = Evereska, Western Heartlands | sexo = Female | raça = Moon half-elf | calendário = CV | classe3e = | refs3e = | tendência3e = Caótica e Boa | nocat = true }} This example will place the page in the following categories: * Categoria:Guerreiros de 4º nível (3e) * Categoria:Guerreiros (3e) * Categoria:Harper agents de 5º nível (3e) * Categoria:Harper agents (3e) * Categoria:Ladinos de 1º nível (3e) * Categoria:Ladinos (3e) The sortkey will ensure that in each of these categories the page is filed under "M" for Moonblade rather than "A" for Arilyn. Usage ; edition : Optional. If this is set, categories will be generated for each class/level pair listed thereafter. Each category will be appended with this value, in parentheses. Values should be: 1e, 2e, 3e, 4e, 5e and so on. By convention, 3.5 edition is considered 3e because the classes did not change significantly between 3rd edition and 3.5, but 3.5 (or whatever you decide) can be used if desired. ; sortkey : Optional. If categories are being generated, then the sortkey will determine where in the alphabetical list of pages your page will appear. The default is to sort by the , but you can change it with this parameter. ; (class names) : The first value in a class/level pair, this will usually be a link to the article describing the class, but it's not required to be a link. ; (levels) : The second value in a class/level pair, this must be a number with no suffix (i.e., use 4''' not '''4th). ; nocat : Setting this to true will suppress the generation of categories. This is primarily used on documentation pages like this one so it doesn't show up in the categories. Notes * Up to ten class/level pairs may be specified. * Classes are typically linked to their description pages, but this is not required. * It is important that you use the class name as you want it to appear in the categories (i.e., do not use Priest, just use Cleric. * You may put tags (or anything else that starts with "<") after either a class or a level. The template should ignore it. However, this will cause misalignment of the columns in the table. Note the template allows citations to be put in the subtitles of edition-specific sections, and this is recommended for the best looking class table. * The sortkey only applies to the dynamic categories generated by this template. If you specify a sortkey, then you should also add a to your page so any static categories will also place your page in the correct alphabetical order. Under the Hood This template is fairly straightforward because most of the brains are in the helper templates: ; : Returns the plural form of a class title. returns . Case is preserved, but the category will use the capitalized version. If new classes are added, and the plural form is something other than adding an "s" suffix, please add them to . ; : Returns everything up to, but not including, the first "<" symbol, if any. This will remove any tags or other HTML markup that might be appended to a string (the level, in this template). ; : Returns the string between square brackets. returns . It shouldn't matter how many brackets are present, including zero. ; : Returns everything up to but not including the first pipe symbol (|). This removes any alt-text of a link. returns . Here is the part of the template that operates on the first class/level pair: } }| } }} }} }} }} }} of } }} }} level ( }) }| }}} } }} }} }} }} }} ( }) }| }}} }} The template is essentially ten repeats of this code block. In English, if the first or second parameter have a value then the next two lines will generate categories (so be sure to specify both a class and a level or the results won't be pretty). Starting with this invocation of the template: The value of } will be the class and the ref tag, thief, the value of } will be the level, 4, the value of } will be 3e, and the value of } will be Baenre, Jarlaxle. Breaking down the first category line, just look at this part: } }} }} }} }} }} [[Category: starts the category tag and then we hit the first set of double braces, , at the end of the line. Working from the inside out, looks for a "<" character and removes it and anything following it, returning [[thief. extracts all characters up to the first pipe symbol (|), but since there isn't one it just returns thief unchanged. Then changes thief to }}. Then changes }} to }}}}. And finally, capitalizes the first letter and returns }}}}}}. So far, we have generated this: } }} }} level ( }) }| }}} The word of is appended, and then we see } }} }}. The value of } is 4 so just returns 4. Next the template changes the 4 to . At this point we have assembled this string: [[Category:Thieves of 4th The word level is appended, and then ( }) appends the value of edition, inside parentheses, to the end. Now we have this: }}}| }}} If } has a value, then we append a vertical bar ( evaluates to the "|" symbol. This is necessary because if we just typed the bar in, the #if: would think we were specifying an else clause.) and the value of sortkey. Finally, the category link is closed with ]], resulting in Baenre, Jarlaxle The other category is even simpler. The ten repetitions of this code block are surrounded by an if statement that checks to see if edition has a value and skips the whole category thing if not. Similarly, one more if statement surrounds everything and will skip the categories if the parameter nocat is set to true. So why does the source code look like a bunch of wavy lines with a few words sprinkled about? Well, the extra whitespace that it takes to make the code almost readable will be part of the return value of the template, and that puts blank lines at the end of the table, at least one for each unused row. Therefore, all of the newline/carriage returns in the code had to be removed, making the template one really long line of wikitext. Sorry. Apêndice Referências